package com.daigoudao.web.model;

import org.apache.commons.lang.StringUtils;

import com.daigoudao.config.ConfigManager;
import com.daigoudao.util.Constants;
import com.daigoudao.util.ImageUtil;

/**
 * 求购信息
 * 
 * @author zheng
 * 
 */
@SuppressWarnings("serial")
public class WantBuyModel extends BasePageModel {

	private int wantId;

	/**
	 * 用户信息
	 */
	private UserModel user = new UserModel();

	/**
	 * 商品名称
	 */
	private String goodsName;

	/**
	 * 价格
	 */
	private float price;

	/**
	 * 币种 1 人民币 2 港币 3 美元 4 欧元 5 日元
	 */
	private int currency;

	/**
	 * 商品图片URL
	 */
	private String image;

	private float serviceFee;

	/**
	 * 服务费比例
	 */
	private int ratio;

	/**
	 * 商品来源 0 不限 1 大型超市 2 便利店 3 专卖店 4 生产厂家 5 其他
	 */
	private int source;

	/**
	 * 单据要求, 0 无要求 1 小票 2 发票 3 小票或是发票
	 */
	private int receipts;

	/**
	 * 商品描述
	 */
	private String description;

	/**
	 * 商品类别编号
	 */
	private int categoryId;

	/**
	 * 商品类别名称
	 */
	private String categoryName;

	/**
	 * 所属区域id
	 */
	private int areaId;

	/**
	 * 所属区域名
	 */
	private String areaName;

	/**
	 * 数量
	 */
	private int number;

	/**
	 * 有效期
	 */
	private String validityPeriod;

	/**
	 * 经纪要求
	 */
	private String brokerReq;

	private String other;

	/**
	 * 排序条件
	 */
	private int order;

	/**
	 * 状态
	 */
	private int status;

	private String ts;

	/**
	 * 搭车求购人数
	 */
	private int simpleBuys;

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public String getOther() {
		return other;
	}

	public void setOther(String other) {
		this.other = StringUtils.trimToEmpty(other);
	}

	public UserModel getUser() {
		return user;
	}

	public void setUser(UserModel user) {
		this.user = user;
	}

	public String getGoodsName() {
		return goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = StringUtils.trimToEmpty(goodsName);
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public int getCurrency() {
		return currency;
	}

	public void setCurrency(int currency) {
		this.currency = currency;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public float getServiceFee() {
		return serviceFee;
	}

	public void setServiceFee(float serviceFee) {
		this.serviceFee = serviceFee;
	}

	public int getRatio() {
		return ratio;
	}

	public void setRatio(int ratio) {
		this.ratio = ratio;
	}

	public int getSource() {
		return source;
	}

	public void setSource(int source) {
		this.source = source;
	}

	public int getReceipts() {
		return receipts;
	}

	public void setReceipts(int receipts) {
		this.receipts = receipts;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = StringUtils.trimToEmpty(description);
	}

	public int getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(int categoryId) {
		this.categoryId = categoryId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public int getAreaId() {
		return areaId;
	}

	public void setAreaId(int areaId) {
		this.areaId = areaId;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public int getWantId() {
		return wantId;
	}

	public void setWantId(int wantId) {
		this.wantId = wantId;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public String getValidityPeriod() {
		return validityPeriod;
	}

	public void setValidityPeriod(String validityPeriod) {
		if (validityPeriod.length() >= 10) {
			this.validityPeriod = validityPeriod.substring(0, 10);
		} else {
			this.validityPeriod = validityPeriod;
		}
	}

	public String getBrokerReq() {
		return brokerReq;
	}

	public void setBrokerReq(String brokerReq) {
		this.brokerReq = StringUtils.trimToEmpty(brokerReq);
	}

	public String getAbsoluteImagePath() {
		if (image != null && !StringUtils.isBlank(image)) {
			return ConfigManager.getConfigString("upload.resUrl") + image;
		}
		return ConfigManager.getConfigString("upload.resUrl")
				+ Constants.DEFAULT_PRODUCT_PIC;
	}

	public String getTs() {
		return ts;
	}

	public void setTs(String ts) {
		this.ts = ts;
	}

	public int getSimpleBuys() {
		return simpleBuys;
	}

	public void setSimpleBuys(int simpleBuys) {
		this.simpleBuys = simpleBuys;
	}

	/**
	 * 总求购人数
	 * 
	 * @return
	 */
	public int getTotal() {
		return simpleBuys + 1;
	}

	public String getImage200() {
		String imagePath = Constants.DEFAULT_PRODUCT_PIC;
		if (image != null) {
			imagePath = ImageUtil.getImageFileName(image, 200);
		}
		return ConfigManager.getConfigString("upload.resUrl") + imagePath;
	}

	public String getImage50() {
		String imagePath = Constants.DEFAULT_PRODUCT_PIC;
		if (image != null) {
			imagePath = ImageUtil.getImageFileName(image, 50);
		}
		return ConfigManager.getConfigString("upload.resUrl") + imagePath;
	}
}
